﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="Jy123.Web.Manage.Register" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>管理员－注册</title>
    <link href="css/custom/jquery.ui.css" rel="stylesheet" type="text/css" />
    <link href="css/main.css" rel="stylesheet" type="text/css" />
    <script src="js/jquery.js" type="text/javascript"></script>
    <script src="js/jquery.ui.js" type="text/javascript"></script>
    <script src="js/main.js" type="text/javascript"></script>
    <script src="js/reg.js" type="text/javascript"></script>

</head>
<body>
    <form id="form1" runat="server">
    <h4>
        <a href="#"><span>帐户信息</span></a></h4>
    <div class="register">
        <h5>
            用户名</h5>
        <ul>
            <li>
                <input id="txtName" type="text" class="text" runat="server" /></li>
            <li>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="请输入用户名"
                    CssClass="warning" Display="Dynamic" ControlToValidate="txtName" ForeColor=""></asp:RequiredFieldValidator></li>
        </ul>
        <h5>
            密 码</h5>
        请输入您的新密码2次. 建议使用强度高的密码增强安全.
        <ul class="bb">
            <li>
                <input id="pwd" type="password" class="text" runat="server" onkeyup="pwdStrength(this.value)" /></li>
            <li>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="请输入密码"
                    CssClass="warning" Display="Dynamic" ControlToValidate="pwd" ForeColor=""></asp:RequiredFieldValidator>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="pwd"
                    CssClass="warning" Display="Dynamic" ErrorMessage="密码必须大于6小于20" ForeColor=""
                    ValidationExpression="\S{6,20}"></asp:RegularExpressionValidator>
            </li>
            <li><span class="password-strength"><span>低</span><span>中</span><span>高</span></span></li>
        </ul>
        <ul>
            <li>
                <input id="pwd2" type="password" class="text" runat="server" /></li>
            <li>
                <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="pwd"
                    ControlToValidate="pwd2" CssClass="warning" Display="Dynamic" ErrorMessage="两次密码不同"
                    ForeColor=""></asp:CompareValidator>
            </li>
        </ul>
        <h5>
            邮 箱</h5>
        <ul>
            <li>
                <input id="txtEmail" type="text" class="text" runat="server" /></li>
            <li>
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtEmail"
                    CssClass="warning" Display="Dynamic" ErrorMessage="请输入正确的Email" ForeColor=""
                    ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
            </li>
        </ul>
        <h5>
            权限</h5>
        <ul>
            <li>
                <asp:DropDownList ID="dropRight" runat="server">
                </asp:DropDownList>
            </li>
        </ul>
        <ul class="bb">
            <li>
                <asp:Button ID="btnSubmit" CssClass="button" runat="server" Text="注 册" OnClick="btnSubmit_Click" /></li>
        </ul>
    </div>
    <asp:HiddenField ID="hidRightID" runat="server" />
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" CssClass="tblist" 
        DataKeyNames="ID" DataSourceID="SqlDataSource1" 
        onrowdatabound="GridView1_RowDataBound">
        <Columns>
            <asp:TemplateField HeaderText="管理员ID" SortExpression="MName">
                <ItemTemplate>
                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("MName") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" CssClass="tdtext" runat="server" Text='<%# Bind("MName") %>'></asp:TextBox>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Email" SortExpression="Email">
                <ItemTemplate>
                    <asp:Label ID="Label5" runat="server" Text='<%# Bind("Email") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox2" CssClass="tdtext" runat="server" Text='<%# Bind("Email") %>'></asp:TextBox>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="最后登录时间" SortExpression="LastLogin">
                <ItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("LastLogin") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("LastLogin") %>'></asp:Label>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="最后登录IP" SortExpression="LoginIP">
                <ItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("LoginIP") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("LoginIP") %>'></asp:Label>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="权限" SortExpression="FMRight">
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# GetRightName(Eval("FMRight")) %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:HiddenField ID="hidRight" runat="server" Value='<%# Eval("FMRight") %>' Visible="false">
                    </asp:HiddenField>
                    <asp:DropDownList ID="dropRightList" runat="server" onchange="document.all.hidRightID.value=this.value;">
                    </asp:DropDownList>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="操作" ShowHeader="False">
                <ItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" 
                        CommandName="Edit" Text="编辑"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                        CommandName="Delete" Text="删除" ForeColor="#CB6E50"></asp:LinkButton>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" 
                        CommandName="Update" Text="更新"></asp:LinkButton>
                    &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                        CommandName="Cancel" Text="取消" ForeColor="#CB6E50"></asp:LinkButton>
                </EditItemTemplate>
                <ControlStyle CssClass="btnsty" />
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        DeleteCommand="DELETE FROM [Manage_Main] WHERE [ID] = @ID" 
        InsertCommand="INSERT INTO [Manage_Main] ([MName], [Email], [LastLogin], [LoginIP], [FMRight]) VALUES (@MName, @Email, @LastLogin, @LoginIP, @FMRight)" 
        SelectCommand="SELECT [MName], [Email], [LastLogin], [LoginIP], [FMRight], [ID] FROM [Manage_Main]" 
        UpdateCommand="UPDATE [Manage_Main] SET [MName] = @MName, [Email] = @Email, [FMRight] = @FMRight WHERE [ID] = @ID">
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="MName" Type="String" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:ControlParameter ControlID="hidRightID" Name="FMRight" PropertyName="Value" Type="Int32" />
            <asp:Parameter Name="ID" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="MName" Type="String" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:Parameter DbType="Date" Name="LastLogin" />
            <asp:Parameter Name="LoginIP" Type="String" />
            <asp:Parameter Name="FMRight" Type="Int32" />
        </InsertParameters>
    </asp:SqlDataSource>
    <% =Message %>
    </form>
</body>
</html>
